package com.mes.utils;

public class SendMessageUtil {

	/**
	 * 通过消息编码，传入消息头、消息内容发送消息
	 * @param msgCode
	 * @param title
	 * @param text
	 */
	public static void sendMessage(String msgCode, String title, String text) {
		String sql = "{call Mes_Message.send(?, ?, ?)}";
		DBConctionQuery conn = null;
		try {
			conn = new DBConctionQuery();
			conn.execute(sql, msgCode, title, text);
			
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			if (conn != null) {
				conn.close();
			}
		}
	}
	
	/**
	 * 通过消息编码，传入消息头、消息内容发送消息
	 * @param msgCode
	 * @param title
	 * @param text
	 */
	public static void sendMessage(String msgCode, String title, String text, String userId) {
		String sql = "{call Mes_Message.send(?, ?, ?, '', ?)}";
		DBConctionQuery conn = null;
		try {
			conn = new DBConctionQuery();
			conn.execute(sql, msgCode, title, text, userId);
			
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			if (conn != null) {
				conn.close();
			}
		}
	}

	/**
	 * 通过消息编码，传入消息头、消息内容发送消息
	 * @param msgCode
	 * @param title
	 * @param text
	 */
	public static void sendMessage(String msgCode, String title, String text, String orgId,String userId) {
		String sql = "{call Mes_Message.send(?, ?, ?, ?, ?)}";
		DBConctionQuery conn = null;
		try {
			conn = new DBConctionQuery();
			conn.execute(sql, msgCode, title, text, orgId,userId);

		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			if (conn != null) {
				conn.close();
			}
		}
	}
	
	/**
	 * 通过消息编码发送消息提醒
	 * @param msgCode
	 */
	public static void sendMessage(String msgCode) {
		String sql = "{call Mes_Message.send(?)}";
		DBConctionQuery conn = null;
		try {
			conn = new DBConctionQuery();
			conn.execute(sql, msgCode);
			
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			if (conn != null) {
				conn.close();
			}
		}
	}
	/**
	 * 通过消息编码发送消息提醒
	 * @param msgCode
	 */
	public static void sendMessage(String msgCode, String userId) {
		String sql = "{call Mes_Message.send(?, '', '', '', ?)}";
		DBConctionQuery conn = null;
		try {
			conn = new DBConctionQuery();
			conn.execute(sql, msgCode, userId);
			
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			if (conn != null) {
				conn.close();
			}
		}
	}
}